package cn.tianyigps.tianyigpsapiv2.param.dto;

import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Author: LiuHao
 * @Descirption:
 * @Date: 2019/4/8_13:49
 */
@Getter
@Setter
public class FenceDTO extends BaseDTO {

    private static final long serialVersionUID = -7047530413221795080L;

    private String group;//分组

    private Set<String> tags;

    //多边形围栏经纬度List
//    private List<Point> points;
    private List<Map> points;

    private String description;//描述

    public static final String SAVE_API_NAME = "Fence.Save";

    @Override
    public boolean checkParam(String method) {
        switch (method){
            case SAVE_API_NAME:
                return checkSave();
            default:
                return false;
        }

    }

    private boolean checkSave(){
        //组校验
        if(StringUtils.isEmpty(this.getGroup())){
            return false;
        }
        //区域校验
        if(CollectionUtils.isEmpty(this.getPoints())){
            return false;
        }
//        //tags校验
//        if(CollectionUtils.isEmpty(this.getTags())){
//            return false;
//        }
//        //描述
//        if(!StringUtils.isEmpty(this.getDescription())){
//            return false;
//        }
        return true;
    }
}
